import 'package:flutter/material.dart';
import 'package:flutter_app/widgets/bottom_nav.dart';
import 'package:flutter_app/views/Credit/index.dart';
import 'package:flutter_flipperkit/flutter_flipperkit.dart';
import 'package:flipperkit_redux_middleware/flipperkit_redux_middleware.dart';

import 'package:redux/redux.dart';
import 'package:flutter_app/redux/state.dart';
import 'package:flutter_app/model/user.dart';
import 'package:flutter_redux/flutter_redux.dart';

void main() {
  FlipperClient flipperClient = FlipperClient.getDefault();

  flipperClient.addPlugin(new FlipperNetworkPlugin());
  flipperClient.addPlugin(new FlipperReduxInspectorPlugin());
  flipperClient.start();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  final store = new Store<APPState>(appReducer,
      middleware: []..add(new FlipperKitReduxMiddleware(
          filter: (actionType) {
            return actionType.startsWith('\$');
          },
          getActionType: (action) {
            return action.toString();
          },
        )),
      initialState: new APPState(
        userInfo: User.empty(),
      ));

  MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return StoreProvider(
      store: store,
      child: MaterialApp(
        home: BottomNav(),
        theme: new ThemeData(primaryColor: Colors.white),
        routes: {
          '/home': (BuildContext context) => new Credit(),
        },
      ),
    );
  }
}
